#!/bin/bash
source /etc/profile
if [ -n "$1" ] ;then
do_date=$1
else
do_date=`date -d "-1 day" +%F`
fi
sql="
insert overwrite table dim.dim_trade_shops
select shopid,
userid,
areaid,
shopname,
shoplevel,
status,
createTime,
modifyTime,
start_dt,end_dt
from dim.dim_trade_shops
where end_dt< '$do_date'
union all
select shopid,
userid,
areaid,
shopname,
shoplevel,
status,
createTime,
modifyTime,
start_dt,'9999-12-31' end_dt
from dim.dim_trade_shops
where start_dt <= '$do_date' and end_dt >= '$do_date';"

hive -e "$sql"
